<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>计算属性的 getter 和 setter</title>
	</head>
	<body>
		<div id="app">
			firstName:<input type="text" name="" id="" value="" v-model="firstName" />
			lastName:<input type="text" name="" id="" value="" v-model="lastName" /><br>
			<p>fullName:<input type="text" name="" id="" value="" v-model="fullName" /></p>
		</div>
		<script src="../js/vue.js"></script>
		<script type="text/javascript">
			var vm = new Vue({
				el: '#app',
				data: {
					firstName: 'Jack',
					lastName: 'Jones',
				},
				computed: {
					fullName: {
						// getter
						get: function() {
							return this.firstName + ' ' + this.lastName
						},
						// setter
						set: function(newValue) {
							var names = newValue.split(' ')
							this.firstName = names[0]
							this.lastName = names[names.length - 1]
						}
					}
				}
			})
		</script>

	</body>
</html>
